#ifndef COMPLEXPROXYMODEL_H
#define COMPLEXPROXYMODEL_H



#include "SimpleProxyModel.h"



typedef QMap<ProxyIndex, IndexMap> IndexTree;
typedef QMapIterator<ProxyIndex, IndexMap> IndexTreeIterator;


class ComplexProxyModel : public SimpleProxyModel
{
    Q_OBJECT

public:

    enum ComplexFilter
    {
        ComplexFilter_FIRST = SimpleFilter_LAST + 1,
        TreeFilter = ComplexFilter_FIRST,
        ElevateFilter,
        ComplexFilter_LAST = ElevateFilter
    };

    ComplexProxyModel(QObject *parent = 0);

    virtual QModelIndex index(int row, int column, const QModelIndex &proxyParent) const;
    virtual QModelIndex parent(const QModelIndex &proxyChild) const;

    virtual int rowCount(const QModelIndex &proxyParent) const;
    virtual int columnCount(const QModelIndex &proxyParent) const;

    virtual QModelIndex mapFromSource(const QModelIndex &sourceIndex) const;
    virtual QModelIndex mapToSource(const QModelIndex &proxyIndex) const;

    void addComplexFilter(const QString& idPattern, const int& filter = EndsWithFilter);
    int complexFilter(const QString& itemId) const;

protected slots:

    //virtual void onRowsInserted(const QModelIndex& sourceParent, int start, int end);
    //virtual void onRowsRemoved(const QModelIndex& sourceParent, int start, int end);

    virtual void mapChildren(const QModelIndex& sourceParent = QModelIndex(), int start = 0);
    virtual void mapComplex(const QModelIndex& sourceIndex, const QModelIndex& sourceParent, const int& filter);

protected:

    IndexTree m_indexTree;

    QMap<QString, int> m_complexeds;

};

#endif // COMPLEXPROXYMODEL_H
